﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;

class Solution
{
    static void Main(String[] args)
    {
        string input = "253.18.19.20";
        string patternIP4 = @"(((2((5[0-5])|[0-4][0-9])))|([0-1]?[0-9]{1,2})\.)" +
            @"(((2((5[0-5])|[0-4][0-9])))|([0-1]?[0-9]{1,2})\.)" +
            @"(((2((5[0-5])|[0-4][0-9])))|([0-1]?[0-9]{1,2})\.)" +
            @"(((2((5[0-5])|[0-4][0-9])))|([0-1]?[0-9]{1,2}))";

        //MatchCollection matchCollection = Regex.Matches(input, patternIP4);
        //foreach (Match match in matchCollection)
        //{
        //    Console.WriteLine(match.Value);
        //}
        Match match = Regex.Match(input, patternIP4);
        //match = Regex.Match("76.4", @"([0-9]+)|([a-z]+)\.[0-9]+");
        if (match.Success)
        {
            Console.WriteLine(match.Value);
        }

        Console.ReadKey();
    }
}